package com.ruoyi.app.mapper;

import com.ruoyi.app.domain.ArticleInfo;
import com.ruoyi.app.domain.ArticleInfoExample;
import com.ruoyi.app.dto.ArticleDto;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

public interface ArticleInfoMapper {
    int countByExample(ArticleInfoExample example);

    int deleteByExample(ArticleInfoExample example);

    int deleteByPrimaryKey(Long id);

    int insert(ArticleInfo record);

    int insertSelective(ArticleInfo record);

    List<ArticleInfo> selectByExampleWithBLOBs(ArticleInfoExample example);

    List<ArticleInfo> selectByExample(ArticleInfoExample example);

    ArticleInfo selectByPrimaryKey(Long id);

    int updateByExampleSelective(@Param("record") ArticleInfo record, @Param("example") ArticleInfoExample example);

    int updateByExampleWithBLOBs(@Param("record") ArticleInfo record, @Param("example") ArticleInfoExample example);

    int updateByExample(@Param("record") ArticleInfo record, @Param("example") ArticleInfoExample example);

    int updateByPrimaryKeySelective(ArticleInfo record);

    int updateByPrimaryKeyWithBLOBs(ArticleInfo record);

    int updateByPrimaryKey(ArticleInfo record);


    @Update("UPDATE article_info SET article_thumbs = COALESCE ( article_thumbs, 0 ) + 1 WHERE id = #{id}")
    int upArticleInfoThumbs(Long id);

    @Update("UPDATE article_info SET article_thumbs = GREATEST(COALESCE(article_thumbs, 0) - 1, 0) WHERE id = #{id}")
    int downArticleInfoThumbs(Long id);


    List<ArticleDto> getArticleInfoList(Map<String, Object> params);

    ArticleInfo getArticleInfo(Long id);
}